/**
 * 项目审批 编辑页
 *
 * 作者 ganjun
 * 日期 2024-11-16 21:20:36
 */
layui.use(['jquery','febs', 'form', 'validate'], function () {
    var $ = layui.$,
        febs = layui.febs,
        layer = layui.layer,
        form = layui.form,
        $view = $('#workflowRecord-edit'),
        validate = layui.validate;

    form.verify(validate);
    form.render();
    initFormValue();

    function initFormValue() {
        if (workflowRecordData) {
            form.val("workflowRecord-edit-form", {
                "id": workflowRecordData.id,
                "voucherType": workflowRecordData.voucherType,
                "voucherId": workflowRecordData.voucherId,
                "status": workflowRecordData.status,
                "remark": workflowRecordData.remark,
            });
        }
    }

    form.on('submit(workflowRecord-edit-form-submit)', function (data) {
        addOrUpdate(data.field);
        return false;
    });

    function addOrUpdate(data) {
        var url='workflowRecord/update';
           if(data.voucherType==5){
              url='sypqProject/saveAudit';
           }
            if (data.id && data.id.length > 0) {
                febs.postArray(ctx + url, data, function () {
                    layer.closeAll();
                    febs.alert.success('审批成功');
                });
            } else {
                     febs.alert.success('提交失败');
            }
           if(data.voucherType==5) {
                $('#febs-sypqProject').find('#query').trigger('click');
             }
    }


});